package nz.ac.massey.jfontview.example;

import java.awt.Font;

import javax.swing.JComponent;
import javax.swing.JFrame;

import nz.ac.massey.jfontview.FontList;
import nz.ac.massey.jfontview.FontSelector;

import org.nutj.swing.PrettyDialog;

/**
 * Dialog for displaying font selector.
 * @author Carl Robinson
 * @author Nathan C Jones
 * @version 0.1
 */
public class FontDialog extends PrettyDialog<Font>{

	private static final long serialVersionUID = 3203432477120192978L;
	
	private FontSelector fontSelector;
	
	/**
	 * @param frame
	 * @param favourites
	 */
	public FontDialog(JFrame frame, FontList favourites){
		super(frame,"Select Font");
		fontSelector = new FontSelector(favourites);
		init();
	}

	/**
	 * @param frame
	 */
	public FontDialog(JFrame frame){
		this(frame,new FontList());
	}

	/**
	 * @return
	 */
	public FontList getFavouriteFonts(){
		return fontSelector.getFavouriteFonts();
	}

	/**
	 * @return
	 */
	@Override
	protected Font getResult(){
		return fontSelector.getSelectedFont();
	}

	@Override
	protected JComponent getDialogContent(){
		return fontSelector==null?super.getDialogContent():fontSelector;
	}
}